package com.gitee.aop;


import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.Instant;

/**
 * <p>
 * 保存检索日志
 * </p>
 *
 * @author acao
 * @since 2024-02-06
 */
@Aspect // AOP注解
@Order(Ordered.HIGHEST_PRECEDENCE)
@Component
@AllArgsConstructor
public class SaveLogAspect {

    ObjectMapper objectMapper;

    /**
     * 切入点
     */
    @Pointcut("@annotation(AnnotationSaveSearchLog)")
    public void aspectSaveSearchLog() {
    }


    /**
     * AOP：保存重要请求的日志
     *
     * @param pjp ProceedingJoinPoint
     * @return 返回数据
     * @throws Throwable 异常
     */
    @Around("aspectSaveSearchLog()")
    public Object saveReqLogService(ProceedingJoinPoint pjp) throws Throwable {
        // 请求开始时间
        Instant start = Instant.now();
        return null;
    }

}
